﻿
Imports storoomc

Partial Public MustInherit Class storoomOper
    Private Class STOROOMOPER_COUNTERS
        Private Shared _READ As Int64
        Private Shared _WRITE As Int64
        Private Shared _DELETE As Int64
        Private Shared _SEEK As Int64
        Private Shared _LIST As Int64
        Private Shared _MODIFY As Int64
        Private Shared _SIZEOF As Int64
        Private Shared _RETIRE As Int64

        Private Shared Function registerAverageAndLastAverage(ByVal name As String) As Int64
            Return counter.registerAverageAndLastAverage("STOROOMOPER_" + name + "_TIMEMS")
        End Function

        Shared Sub New()
            _READ = registerAverageAndLastAverage("READ")
            _WRITE = registerAverageAndLastAverage("WRITE")
            _DELETE = registerAverageAndLastAverage("DELETE")
            _SEEK = registerAverageAndLastAverage("SEEK")
            _LIST = registerAverageAndLastAverage("LIST")
            _MODIFY = registerAverageAndLastAverage("MODIFY")
            _SIZEOF = registerAverageAndLastAverage("SIZEOF")
            _RETIRE = registerAverageAndLastAverage("RETIRE")
        End Sub

        Private Shared Sub increase(ByVal id As Int64, ByVal ticks As Int64)
            counter.increase(id, ticksToMilliseconds(ticks))
        End Sub

        Public Shared Sub read(ByVal ticks As Int64)
            increase(_READ, ticks)
        End Sub

        Public Shared Sub write(ByVal ticks As Int64)
            increase(_WRITE, ticks)
        End Sub

        Public Shared Sub delete(ByVal ticks As Int64)
            increase(_DELETE, ticks)
        End Sub

        Public Shared Sub seek(ByVal ticks As Int64)
            increase(_SEEK, ticks)
        End Sub

        Public Shared Sub list(ByVal ticks As Int64)
            increase(_LIST, ticks)
        End Sub

        Public Shared Sub modify(ByVal ticks As Int64)
            increase(_MODIFY, ticks)
        End Sub

        Public Shared Sub sizeof(ByVal ticks As Int64)
            increase(_SIZEOF, ticks)
        End Sub

        Public Shared Sub retire(ByVal ticks As Int64)
            increase(_RETIRE, ticks)
        End Sub
    End Class
End Class
